#pragma once
#include "al_SingleTargetAbility.h"
#include "StatePlaying.h"
#include "UnitManager.h"
namespace ability
{

	//struct ability_point : public sf::Vector2u, public ability::IAbilityTarget
	//{

	//};

	class Ability_MoveUnit	:	public ability_types::SingleTargetAbility<sf::Vector2u>
	{
		public:
		Ability_MoveUnit(game::Unit * ownerPtr):ability_types::SingleTargetAbility<sf::Vector2u>("MoveUnit",ownerPtr,0,0,0){}
		~Ability_MoveUnit(){};
		void action()
		{
			static_cast<game::Unit*>((*this).getOwner())->MoveToPoint(*getSelectedTarget());
		}
	};

	class Ability_MoveToNearestUnit	: public ability_types::SingleTargetAbility<game::UnitManager>
	{
		public:
			Ability_MoveToNearestUnit(game::Unit * ownerPtr):ability_types::SingleTargetAbility<game::UnitManager>("MoveUnitToNearestUnit",ownerPtr,0,0,0){}
		~Ability_MoveToNearestUnit(){};
		void action()
		{
			game::Unit * owner = static_cast<game::Unit*>((*this).getOwner());
			game::UnitManager * manager = this->getSelectedTarget();
			game::Unit * closestUnit = manager->get_closest_unit(owner);
			if (closestUnit != NULL)
			owner->MoveToPoint(closestUnit->get_position());
			//static_cast<game::Unit*>((*this).getOwner())->MoveToPoint(this->getSelectedTarget());
		}
	};

	class Ability_HurtSelf : public ability_types::BasicAbility
	{
	public :
		Ability_HurtSelf(game::Unit * ownerPtr,int amount):ability_types::BasicAbility("Hurt Self",ownerPtr,amount,0,0){}
		~Ability_HurtSelf(){};
		bool condition()
		{
			//Unit has to be alive//
			game::Unit * owner = static_cast<game::Unit*>((*this).getOwner());
			if (owner->get_state() == game::UnitState::S_UNIT_DEAD){return false;}
			else {return true;}
		
		}
		void action()
		{
			game::Unit * owner = static_cast<game::Unit*>((*this).getOwner());
			owner->get_current_stats().addHp(-getAmount(),owner->get_max_stats().getHp());
			std::cout << owner->get_current_stats().getHp() << std::endl;
		}
	};

}